#include "TextureIdPool.h"

namespace core {

	GLuint* TextureIdPool::_textures = 0;
	int TextureIdPool::_count = 0;
	std::queue<GLuint> TextureIdPool::_freeTextures;

	void TextureIdPool::Create(GLuint count)
	{
		_count = count;
		_textures = new GLuint[count];
		glGenTextures( _count, _textures );
		for(int i = 0; i < _count; ++i)
			_freeTextures.push(_textures[i]);
	}

	void TextureIdPool::Destroy()
	{
		glDeleteTextures( _count, _textures );
	}

	GLuint TextureIdPool::Take(){
		GLuint tex = _freeTextures.front();
		_freeTextures.pop();
		return tex;
	}

	void TextureIdPool::Put(GLuint texId){
		_freeTextures.push(texId);
	}

}
